package Dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;

import OracleHelper.OracleHelper;

import Entity.*;

@Component("sid")
public class SpringMVC_StudentsInformationDao {
	@Resource(name = "jdbcTemplate")
	private JdbcTemplate jdbcTemplate;

	public List<Student> showAllStudents(){
		List<Student> slist=new ArrayList<Student>();
		String sql="select * from studentsInformation";
		slist = jdbcTemplate.query(sql, new RowMapper<Student>() {
			@Override
			public Student mapRow(ResultSet rs, int rowNum) throws SQLException {
				Student stu = new Student();
				stu.setStudentNo(rs.getString(1));
				stu.setStudentName(rs.getString(2));
				stu.setSex(rs.getString(3));
				stu.setDept(rs.getString(4));
				stu.setMajor(rs.getString(5));
				stu.setStudentClass(rs.getString(6));
				stu.setStudentId(rs.getString(7));
				stu.setPwd(rs.getString(8));
				stu.setTel(rs.getString(9));
				/*
				 * cus.setId(rs.getString(1)); cus.setName(rs.getString(2));
				 * cus.setPhone(rs.getString(3));
				 */
				return stu;
			}
		});
		return slist;

}}
